package com.yan.domainjob;

public class Rectangle extends Graphic{
    private double chang;
    private double kuan;

    public Rectangle(double chang, double kuan) {
        this.chang = chang;
        this.kuan = kuan;
    }

    public Rectangle() {
    }

    public double getChang() {
        return chang;
    }

    public void setChang(double chang) {
        this.chang = chang;
    }

    public double getKuan() {
        return kuan;
    }

    public void setKuan(double kuan) {
        this.kuan = kuan;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Rectangle rectangle = (Rectangle) o;

        if (Double.compare(rectangle.chang, chang) != 0) return false;
        return Double.compare(rectangle.kuan, kuan) == 0;
    }

    @Override
    public String toString() {
        return "Rectangle{" +
                "chang=" + chang +
                ", kuan=" + kuan +
                '}';
    }

    @Override
    public int hashCode() {
        int result;
        long temp;
        temp = Double.doubleToLongBits(chang);
        result = (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(kuan);
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        return result;
    }

    @Override
    public double getArea() {
        return chang * kuan;
    }

    @Override
    public double getPerimeter() {
        return (chang + kuan) * 2 ;
    }

    @Override
    public String getInfo() {
        return "矩形长为:" + chang + "宽为:" + kuan;
    }
}
